<template>
  <div>
    <v-snackbar v-model="show" :timeout="timeout" :color="color" bottom>
      {{ text }}
    </v-snackbar>
  </div>
</template>

<script>
export default {
  name: 'toast',
  data() {
    return {
      show: false,
      text: '',
      color: '',
      timeout: 2000
    }
  },
  methods: {
    info(text, opt = {}) {
      this.color = 'blue darken-3'
      this.text = text
      if (opt.timeout) {
        this.timeout = opt.timeout
      }
      this.show = true
    },
    error(text, opt = {}) {
      this.color = 'pink accent-3'
      this.text = text
      if (opt.timeout) {
        this.timeout = opt.timeout
      }
      this.show = true
    },
    warn(text, opt = {}) {
      this.color = 'orange darken-4'
      this.text = text
      if (opt.timeout) {
        this.timeout = opt.timeout
      }
      this.show = true
    },
    success(text, opt = {}) {
      this.color = 'green darken-2'
      this.text = text
      if (opt.timeout) {
        this.timeout = opt.timeout
      }
      this.show = true
    }
  }
}
</script>

<style scoped></style>
